/**
 * author wen
 * cunyu
 * email wjd_13@hotmail.com
 */
package com.cunyu.service;

import cn.tom.kit.StringUtil;
import com.cunyu.bean.Form;
import com.cunyu.bean.ReqData;
import com.cunyu.bean.RespData;
import com.cunyu.dao.DBQuery;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 反馈 申诉等业务
 * @author win
 * 2019/04/29-10:52
 */
@Service
public class FeedBackService extends BaseService{

    /**
     *  按类型查询数据
     */
    public RespData<List<Map<String, Object>>> typePage(ReqData reqData){
        reqData.setSort("ctime");
        reqData.setOrder("desc");
        String sql = "select * from feedback where oid = 0 " ;
        return page(sql,reqData) ;
    }

    public RespData<List<Map<String, Object>>> orderTypePage(ReqData reqData, Form form) {
        reqData.setSort("f.ctime");
        reqData.setOrder("desc");
        String sql = "select f.*,p.oid pid ,p.state pstate  " +
                " from feedback f ,myOrder p where f.oid = p.id and f.oid > 0";
        DBQuery query = new DBQuery(sql) ;
        if(StringUtil.hasLength(form.getState())){
            query.and(" p.state = ? ").setParams(Integer.valueOf(form.getState())) ;
        }
        return page(query.getSql(),reqData,query.getParams()) ;
    }
}
